package com.sf.dlb.service;

import com.sf.dlb.jpa.model.UserDlbRecordInfo;
import com.sf.dlb.jpa.repository.UserDlbRecordRepository;
import com.sf.dlb.utils.GsonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Created by jing.tan on 2018/5/21.
 */
@Service
public class BaseUserDlbRecordService {
    private static Logger logger = LoggerFactory.getLogger(BaseUserDlbRecordService.class);

    @Autowired
    private UserDlbRecordRepository userDlbRecordRepository;
    /**
     * 生成dlb记录
     * @param userId
     * @param source
     * @param dlbNumber
     * @param dlbType
     */
    public void generateDlbRecord(String userId,String source,String sourceDesc,Double dlbNumber,String dlbType){
        UserDlbRecordInfo userDlbRecordInfo=new UserDlbRecordInfo();
        userDlbRecordInfo.setUserId(userId);
        userDlbRecordInfo.setSource(source);
        userDlbRecordInfo.setSourceDesc(sourceDesc);
        userDlbRecordInfo.setDlbNumber(dlbNumber);
        userDlbRecordInfo.setDlbType(dlbType);
        userDlbRecordInfo.setCreateDate(new Date());
        userDlbRecordInfo.setUpdateDate(new Date());
        logger.info("generateDlbRecord userId"+ GsonUtils.getInstance().toJson(userDlbRecordInfo));
        userDlbRecordRepository.save(userDlbRecordInfo);
    }

}
